package com.qiuling.iot.controller;

import com.qiuling.iot.aop.annotation.MyLog;
import com.qiuling.iot.entity.EquipmentData;
import com.qiuling.iot.service.EquipmentDataService;
import com.qiuling.iot.utils.DataResult;
import com.qiuling.iot.vo.req.EquipmentDataReqVO;
import com.qiuling.iot.vo.resp.PageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author：zhangqiang
 * @Description：
 * @Date：Created in 17:23 2020/3/12
 * @Modified By：
 */
@RestController
@RequestMapping("api")
@Api(tags = "设备管理-收发数据管理", description = "设备管理相关接口")
public class EquipmentDataController {

    @Autowired
    private EquipmentDataService equipmentDataService;

    @PostMapping("/equipmentData")
    @ApiOperation(value = "分页查找操作日志接口")
    @RequiresPermissions("sys:equipmentData:list")
    public DataResult<PageVO<EquipmentData>> pageInfo(@RequestBody EquipmentDataReqVO vo) {
        PageVO<EquipmentData> equipmentDataPageVO = equipmentDataService.pageInfo(vo);
        DataResult result = DataResult.success();
        result.setData(equipmentDataPageVO);
        return result;
    }

    @DeleteMapping("/deleteData")
    @ApiOperation(value = "删除信息接口")
    @MyLog(title = "设备管理-收发数据管理", action = "删除信息接口")
    @RequiresPermissions("sys:equipmentData:delete")
    public DataResult deleteData(@RequestBody @ApiParam(value = "信息ids")List<String> dataIds) {
        equipmentDataService.deleteData(dataIds);
        DataResult result = DataResult.success();
        return result;
    }
}
